package gui;

import java.awt.Graphics;
import java.awt.Image;

import core.Main;

/**
 * A class to handle the menu's cursor.
 * @author nick-luca.frank
 *
 */
public class MenuCursor{
	private int position;
	private Image menuCursor;
	
	/**
	 * Initializes the cursor on the position 0 and Loads the cursor image.
	 */
	public MenuCursor(){
		this.position = 0;
		menuCursor = Main.imageLoader.load("/gui/MenuCursor.png");
	}
	
	/**
	 * Moves the cursor up by one unit.
	 */
	public void up(){
		if(position > 0){
			position--;
		}
	}
	
	/**
	 * Moves the cursor down by one unit.
	 * @param maxPos the 
	 */
	public void down(int maxPos){
		if(position < maxPos-1){
			position++;
		}
	}
	
	/**
	 * Resets the cursor-position to 0.
	 */
	public void reset(){
		position = 0;
	}
	
	public void setPosition(int pos){
		position = pos;
	}
	
	/**
	 * @return the cursor-position
	 */
	public int getPosition(){
		return position;
	}
	
	/**
	 * Renders the cursor.
	 * @param g the Graphics-handle to draw with
	 */
	public void render(Graphics g) {
		g.drawImage(menuCursor, Main.WIDTH - 260, 10 + position * 64, 256, 64, null);
	}
}
